package com.bite.system.domain.system;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bite.common.core.domain.BaseEntity;
import com.bite.system.domain.system.dto.SysUserAddDTO;
import com.bite.system.utils.BCryptUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;


@Getter
@Setter
@TableName("tb_sys_user")
@ToString
public class SysUser extends BaseEntity {
    @TableId(type = IdType.ASSIGN_ID) // 雪花算法
    private Long userId;
    private String nickName; // 别名
    private String userAccount;
    private String password;


    public SysUser() {
        super();
    }

    public static SysUser createByDTO(SysUserAddDTO sysUserSaveDTO) {

        SysUser sysUser = new SysUser();
        sysUser.setUserAccount(sysUserSaveDTO.getUserAccount());
        sysUser.setPassword(BCryptUtils.encryptPassword(sysUserSaveDTO.getPassword()));
        return sysUser;
    }
}
